const path = require("path")
//启用热更新
const webpack = require("webpack")

const htmlWebackPlugin = require("html-webpack-plugin")


module.exports = {
    entry:path.join(__dirname,"./src/main.js"),
    output:{
        path: path.join(__dirname,"./dist"),
        filename: "bundle.js"
    },
    plugins:[
        //配置热更新对象
        new webpack.HotModuleReplacementPlugin(),
        ////创建在内存中生成html插件
        new htmlWebackPlugin({
            template: path.join(__dirname,'./src/index.html'),
            filename: "index.html"
        })
    ],
    module:{
        rules:[
            {test:/\.css$/,use:['style-loader','css-loader']},
            {test:/\.less$/,use:['style-loader','css-loader','less-loader']},
            {test:/\.sass|scss$/,use:['style-loader','css-loader','sass-loader']},
            {test:/\.(jpg|gif|bmp|jpeg|png)$/,use:['url-loader?limit=9125&name=[hash:8]-[name].[ext]']},
            {test:/\.(ttf|svg|eot|svg|woff|woff2)$/,use:['url-loader']},
            {test:/\.js$/,use:'babel-loader',exclude:/node_modules/},
            {test: /\.vue$/, use: 'vue-loader'}
        ]
    },
    //引用vue的第二种方式
    resolve:{
        alias:{
            "vue$":"vue/dist/vue.js"
        }
    }
}